package org.lex.collection.tree.diff;

import java.util.HashSet;
import java.util.Set;

import org.lex.collection.IdentityHashSet;
import org.lex.collection.tree.ITreeNode;

public class DiffSet {
	public Set<ITreeNode> added = new IdentityHashSet<ITreeNode>();
	public Set<ITreeNode> deleted = new IdentityHashSet<ITreeNode>();
	public Set<Diff<ITreeNode>> sameOrUpdate = new HashSet<Diff<ITreeNode>>();

	public void addSameOrUpdated(ITreeNode oldObject, ITreeNode newObject) {
		sameOrUpdate.add(Diff.valueOf(oldObject, newObject));
	}

	public String toString() {
		StringBuilder buf = new StringBuilder();
		buf.append("ADD: ").append(added).append('\n');
		buf.append("DEL: ").append(deleted).append('\n');
		buf.append("S&U: ").append(sameOrUpdate).append("\n");
		return buf.toString();
	}
}